/*
    RExLib project, file rvector.h
    Copyright (C) 2012  Sarvaritdinov Ravil ra9oaj@gmail.com

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
*/

#ifndef RVECTOR_H
#define RVECTOR_H

#include <stdlib.h>
#include <string.h>
#include <malloc.h>

namespace rex {

template <typename T> class RVector
{

public:
    typedef T* iterator;

    RVector<T>();
    RVector<T> ( const RVector<T>& other );
    ~RVector();
    RVector& operator= ( const RVector<T>& other );
    bool operator== ( const RVector<T>& other ) const;
    bool operator!= ( const RVector<T>& other ) const;
    RVector<T>& operator<< ( const T &val );
    T& operator[] ( int i );
    T operator[] ( int i ) const;
    iterator begin() const;
    iterator end() const;
    iterator at ( int pos ) const;
    void insert ( const T &val );
    bool insert ( const T &val, int pos );
    T value ( int id ) const;
    T value ( int id, const T &defaultValue ) const;
    void remove ( int id );
    void remove ( int first, int last);
    void clear();
    int size() const;

private:

    T *_tmp;
    T *_array;
    size_t sz;
    int _cnt;
    int _free;
};

}

#include "rvector.cpp"

#endif // RVECTOR_H
